	/**
	* Loads requested information to main popup div and displays it
	*/
	function OnLoadMainPopup(url, w, h, x, y)
	{
		if( gIsDataLoaded )
		{
			gIsDataLoaded = false;

			jQuery.ajax(
			{
				url: url
				, dataType: "html"
				, success: function(data){OnMainPopupLoaded(data);}
				, error: function(data){OnMainPopupFailed();}
			}
			);

			var popupDiv = jQuery("#MainPopupDiv");


            //alert("Mask width: " + gMaskW + ", height: " + gMaskH);

			//Set height and width to mask to fill up the whole screen
			jQuery("#MainPopupMask").css({ "width": gMaskW, "height": gMaskH }).fadeTo(200, 0.7);

			// Show mask with opacity
			//jQuery("#MainPopupMask").fadeTo(200, 0.7);


			var popupX = isNaN(x) || (x < 1) ? (gMaskW - w) / 2 : x;
			var popupY = isNaN(y) || (y < 1) ? 50 : y;

			popupDiv.css("left", popupX);
			popupDiv.css("top", popupY);

			jQuery("#MainPopupContent").html("<img src='http://jrc.play-and-think.com/images/ajaxloading.gif' alt='loading'/>");

			popupDiv.show();
		}
	}

	function OnMainPopupLoaded(data)
	{
		gIsDataLoaded = true;
		var contentDiv = jQuery("#MainPopupContent");
		contentDiv.html(data).show();
	}

	function OnMainPopupFailed()
	{
		gIsDataLoaded = true;
		var contentDiv = jQuery("#MainPopupContent");
		contentDiv.html("<a href='#' onclick='OnCloseMainPopupClicked(); return false;'><img src='http://jrc.play-and-think.com/images/error.png' alt='Error!' title='Error!' border='0' /></a>");
	}

	function OnCloseMainPopupClicked()
	{
		jQuery("#MainPopupContent").hide();
        jQuery("#MainPopupMask").hide();
	}


	